//
//  WCIAlerter.h
//  WCImApp
//
//  Created by alfie on 2019/11/21.
//  Copyright © 2019 WCImApp. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MOAlerterTableView.h"


typedef NS_ENUM(NSInteger, MOAlerterAnimationOptions) {
    MOAlerterAnimationOptionDefault, // 默认动画，中间弹出
    MOAlerterAnimationOptionBottom,  // 底部弹出
};

@class WCIAlerter;
typedef void(^MOAlerterHandler)(WCIAlerter *alerter);
typedef void(^MOAlerterInputHandler)(WCIAlerter *alerter, UITextField *textField, UILabel *tipLabel);
typedef void(^MOAlerterInputHandler)(WCIAlerter *alerter, UITextField *textField, UILabel *tipLabel);
typedef void(^MOAlerterSheetHandler)(WCIAlerter *alerter, NSInteger index);


@interface WCIAlerter : UIControl

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new  NS_UNAVAILABLE;;


/**
 * 如果需要在屏幕旋转时更新布局，设置该属性 -- 前提：当前控制器必须支持屏幕旋转
 * 默认只支持竖屏：UIInterfaceOrientationMaskPortrait
 * 如果是customView，请自己在外部监听屏幕旋转，手动管理布局
 */
@property (assign, nonatomic) UIInterfaceOrientationMask supportedInterfaceOrientations;

/** 屏幕旋转时，是否隐藏弹窗  --  默认:NO */
@property (assign, nonatomic) BOOL hidesAlerterWhenOrientationDidChang;


/** 快捷创建提示弹窗
 *  只有一个标题和按钮，点击后隐藏弹窗
 *
 *  @param message 标题
 *  @param confirmTitle 按钮标题，默认为 "确定"
 */
+ (instancetype)alertWithMessage:(NSString *)message confirmTitle:(NSString *)confirmTitle;

/** 快捷创建提示弹窗
 *  只有一个标题和按钮，点击后隐藏弹窗
 *
 *  @param message 标题
 *  @param confirmTitle 按钮标题，默认为 "确定"
 *  @param touchHide 点击弹窗以外的范围  是否隐藏弹窗
 */
+ (instancetype)alertWithMessage:(NSString *)message confirmTitle:(NSString *)confirmTitle touchHide:(BOOL)touchHide;

/** 快捷创建提示弹窗
*  只有一个标题和按钮，点击后隐藏弹窗
*
*  @param message 标题
*  @param confirmTitle 按钮标题，默认为 "确定"
*  @param haveClose 默认没有差号按钮
*/
+ (instancetype)alertWithMessage:(NSString *)message confirmTitle:(NSString *)confirmTitle confirmAction:(MOAlerterHandler)confirmAction haveClose:(BOOL)haveClose;

/** 通用弹窗
 * 如果只需要显示一个按钮，可以任意设置 左按钮/右按钮
 *
 * @param title 标题
 * @param message 副标题
 * @param leftTitle 左边按钮标题
 * @param leftAction 点击左边按钮
 * @param rightTitle 右边按钮标题
 * @param rightAction 点击右边按钮
 * @param touchHide 点击弹窗以外的范围  是否隐藏弹窗
 */
+ (instancetype)alertWithTitle:(NSString *)title message:(NSString *)message leftTitle:(NSString *)leftTitle leftAction:(MOAlerterHandler)leftAction rightTitle:(NSString *)rightTitle rightAction:(MOAlerterHandler)rightAction touchHide:(BOOL)touchHide;

+ (instancetype)alertWithTitle:(NSString *)title message:(NSString *)message leftTitle:(NSString *)leftTitle leftAction:(MOAlerterHandler)leftAction rightTitle:(NSString *)rightTitle rightAction:(MOAlerterHandler)rightAction touchHide:(BOOL)touchHide superView:(UIView *)superView;

+ (instancetype)alertCenterWithTitle:(NSString *)title message:(NSString *)message leftTitle:(NSString *)leftTitle leftAction:(MOAlerterHandler)leftAction rightTitle:(NSString *)rightTitle rightAction:(MOAlerterHandler)rightAction touchHide:(BOOL)touchHide superView:(UIView *)superView;

+ (instancetype)alertWithTitle:(NSString *)title message:(NSString *)message leftTitle:(NSString *)leftTitle leftAction:(MOAlerterHandler)leftAction rightTitle:(NSString *)rightTitle rightAction:(MOAlerterHandler)rightAction touchHide:(BOOL)touchHide superView:(UIView *)superView clickNoHide:(BOOL)clickNoHide;

/** 输入框样式的弹窗
 * 如果只需要显示一个按钮，可以任意设置 左按钮/右按钮
 *
 * @param title 标题
 * @param leftTitle 左边按钮标题
 * @param leftAction 点击左边按钮
 * @param rightTitle 右边按钮标题
 * @param rightAction 点击右边按钮
 * @param configuration 自定义textField的样式或行为
 * @param touchHide 点击弹窗以外的范围  是否隐藏弹窗
 */
+ (instancetype)alertInputStyleWithTitle:(NSString *)title message:(NSString *)message leftTitle:(NSString *)leftTitle leftAction:(MOAlerterInputHandler)leftAction rightTitle:(NSString *)rightTitle rightAction:(MOAlerterInputHandler)rightAction textFieldConfiguration:(void (^)(UITextField *textField))configuration touchHide:(BOOL)touchHide;

/** 底部输入框样式的弹窗
 * 用于修改的弹出页面
 *
 * @param title 标题
 * @param tipMessage 提示消息
 * @param rightAction 点击右边按钮 完成
 * @param configuration 自定义textField的样式或行为
 * @param touchHide 点击弹窗以外的范围  是否隐藏弹窗 默认YES
 */
+ (instancetype)alertBottomInputStyleWithTitle:(NSString *)title tipMessage:(NSString *)tipMessage  rightAction:(MOAlerterInputHandler)rightAction textFieldConfiguration:(void (^)(UITextField *textField))configuration touchHide:(BOOL)touchHide btnEnableWhenEmptyString:(BOOL)enable;
///群公告
+ (instancetype)alertBottomInputTextViewWithTitle:(NSString *)title tipMessage:(NSString *)tipMessage  rightAction:(MOAlerterInputHandler)rightAction textFieldConfiguration:(void (^)(UITextView *textView))configuration touchHide:(BOOL)touchHide;
/** 弹出自定义视图
 *
 * @param view 自定义视图
 * @param option 出现的动画
 * @param touchHide 点击弹窗以外的范围  是否隐藏弹窗
 */
+ (instancetype)alertCustomView:(UIView *)view animationOption:(MOAlerterAnimationOptions)option touchHide:(BOOL)touchHide;

/** 弹出自定义视图
 *
 * @param view 自定义视图
 * @param option 出现的动画
 * @param view  父视图 传nil则默认为keywindow
 * @param touchHide 点击弹窗以外的范围  是否隐藏弹窗
 */
+ (instancetype)alertCustomView:(UIView *)view animationOption:(MOAlerterAnimationOptions)option toSuperView:(UIView *)view touchHide:(BOOL)touchHide;

/** 底部带取消样式的列表弹窗
 *
 * @param titles 列表数据源
 * @param cancelTitle 最底部的标题，默认是 "取消"，点击后隐藏弹窗
 * @param action 点击列表的回调
 * @param touchHide 点击弹窗以外的范围  是否隐藏弹窗
 */
+ (instancetype)alertSheetStyleWithTitles:(NSArray *)titles title:(NSString *)title message:(NSString *)message cancelTitle:(NSString *)cancelTitle selectedAction:(MOAlerterSheetHandler)action touchHide:(BOOL)touchHide;


/**
 * 隐藏弹窗
 */
- (void)hide;
///按钮回调 左右通用， 左0 右1
@property (nonatomic, copy) MOAlerterSheetHandler        allAction;

/** tableView */
@property (weak, nonatomic) MOAlerterTableView                  *tableView;

/** 点击背景隐藏回调 */
@property (nonatomic, copy) MOAlerterHandler             touchHideHandler;

/** 异地登录时是否隐藏弹窗，默认YES */
@property (assign, nonatomic) BOOL                  hideWhenLoginByOtherDevice;

/**
 * @brief 更新右边按钮的标题
 */
- (void)makeRightBtnTitle:(NSString *)title;
///启用
- (void)makeRightBtnEnabled:(BOOL)enabled;


@end


